package za.org.jcicada.cfgmngr.impl;

import za.org.jcicada.cfgmngr.ISystemSubject;
import za.org.jcicada.cfgmngr.impl.katcp.ConfigurationKatcpSerializer;
import za.org.jcicada.comms.IConnection;
import za.org.jcicada.comms.IKatcpSerializerStrategy;
import za.org.jcicada.comms.IMessageListener;
import za.org.jcicada.comms.impl.AcceptListenerBase;

/**
 * Katcomms accept listener that accepts connections and ties them to a given
 * ISystemSubject.
 */
public class SystemsAcceptListener extends AcceptListenerBase {

    /**
     * ISystemSubject implementation to delegate requests to.
     */
    protected ISystemSubject systemSubject;

    /**
     * Create an accept listener that listens for clients and passes messages
     * through to the given ISystemSubject implementation.
     */
    public SystemsAcceptListener(ISystemSubject systemSubject) {
        this.systemSubject = systemSubject;
    }

	@Override
	public IMessageListener createListener(IConnection connection) {
		return new SystemsMessaging(connection, systemSubject);
	}

	@Override
	public IKatcpSerializerStrategy getKatcpSerializerStrategy() {
		return new ConfigurationKatcpSerializer();
	}

}
